package ExerChapter12Exception;

import java.util.Scanner;

public class Exer02 {
    public static void main(String[] args) {
        Scanner foo = new Scanner(System.in);
        System.out.println("请输入两个参数以空格隔开");
        try {
            String input = foo.nextLine();
            String[] inputs = input.split(" ");

            if (inputs.length != 2) {
                throw new ArrayIndexOutOfBoundsException("参数个数不对！");
            }

            int a = Integer.parseInt(inputs[0]);
            int b = Integer.parseInt(inputs[1]);
            
            cal(a, b);
        } catch (NumberFormatException e) {
            System.out.println("输入的格式不对");
        } catch (ArithmeticException e) {
            System.out.println("除数必须非0");
        } catch (ArrayIndexOutOfBoundsException e){
            System.out.println(e.getMessage());
        }
    }    
    public static double cal(int a ,int b){
        return a / b;
    }
}
